import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class XuanFu_Widget extends StatefulWidget {
  const XuanFu_Widget({Key? key}) : super(key: key);

  @override
  _XuanFu_WidgetState createState() => _XuanFu_WidgetState();
}

class _XuanFu_WidgetState extends State<XuanFu_Widget>
    with SingleTickerProviderStateMixin {
  ScrollController? _scrollController;

  double topQuickOpacity = 0.0;

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    _scrollController = ScrollController();

    _scrollController!
      ..addListener(() {
        int offset = _scrollController!.offset.ceil();
        this.setState(() {
          topQuickOpacity = offset > 20 ? 1.0 : 0.0;
        });
      });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.white,
      appBar: AppBar(),
      body: Stack(
        children: <Widget>[
          SingleChildScrollView(
            controller: _scrollController,
            child: Column(
              children: <Widget>[
                Text(
                  "小明1",
                  style: TextStyle(fontSize: 50),
                ),
                Text(
                  "小明2",
                  style: TextStyle(fontSize: 50),
                ),
                Text(
                  "小明3",
                  style: TextStyle(fontSize: 50),
                ),
                Text(
                  "小明4",
                  style: TextStyle(fontSize: 50),
                ),
                Text(
                  "小明5",
                  style: TextStyle(fontSize: 50),
                ),
                Text(
                  "小明6",
                  style: TextStyle(fontSize: 50),
                ),
                Text(
                  "小明7",
                  style: TextStyle(fontSize: 50),
                ),
                Text(
                  "小明8",
                  style: TextStyle(fontSize: 50),
                ),
                Text(
                  "小明9",
                  style: TextStyle(fontSize: 50),
                ),
                Text(
                  "小明10",
                  style: TextStyle(fontSize: 50),
                ),
                Text(
                  "小明10",
                  style: TextStyle(fontSize: 50),
                ),
                Text(
                  "小明10",
                  style: TextStyle(fontSize: 50),
                ),
                Text(
                  "小明10",
                  style: TextStyle(fontSize: 50),
                ),
                Text(
                  "小明10",
                  style: TextStyle(fontSize: 50),
                ),
                Text(
                  "小明10",
                  style: TextStyle(fontSize: 50),
                ),
                Text(
                  "小明10",
                  style: TextStyle(fontSize: 50),
                ),
                Text(
                  "小明10",
                  style: TextStyle(fontSize: 50),
                ),
                Text(
                  "小明10",
                  style: TextStyle(fontSize: 50),
                ),
                Text(
                  "小明10",
                  style: TextStyle(fontSize: 50),
                ),
                Text(
                  "小明10",
                  style: TextStyle(fontSize: 50),
                ),
                Text(
                  "小明10",
                  style: TextStyle(fontSize: 50),
                ),
                Text(
                  "小明10",
                  style: TextStyle(fontSize: 50),
                ),
                Text(
                  "小明10",
                  style: TextStyle(fontSize: 50),
                ),
                Text(
                  "小明10",
                  style: TextStyle(fontSize: 50),
                ),
                Text(
                  "小明10",
                  style: TextStyle(fontSize: 50),
                ),
              ],
            ),
          ),
          Positioned(
              child: AnimatedOpacity(
                opacity: topQuickOpacity,
                duration: Duration(
                  milliseconds: 500,
                ),
                child: Container(
                  height: 100,
                  width: double.infinity,
                  color: Colors.green,
                  child: Text(
                    "测试走到了这里",
                    textAlign: TextAlign.center,
                    style: TextStyle(fontSize: 20),
                  ),
                ),
              ))
        ],
      ),
    );
  }
}
